package com.kejiguan.ui.adapter;

import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

import com.kejiguan.ui.R;
import com.kejiguan.ui.model.SheduleActionType;


/**
 * Created by apple on 16/5/12.
 */
public class SheduleOperationAdapter implements SpinnerAdapter{

    private LayoutInflater inflater;
    private SheduleActionType[] actionTypes;

    public SheduleOperationAdapter(Context context,SheduleActionType[] actionTypes)
    {
        inflater=LayoutInflater.from(context);
        this.actionTypes=actionTypes;
    }


    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        SheduleActionType actionType=actionTypes[position];
        View itemView=inflater.inflate(R.layout.dialog_action_item_layout,null);
        TextView actionNameView= (TextView) itemView.findViewById(R.id.operation_name);
        actionNameView.setText(actionType.getActionName());
        return itemView;
    }

    @Override
    public void registerDataSetObserver(DataSetObserver observer) {

    }

    @Override
    public void unregisterDataSetObserver(DataSetObserver observer) {

    }

    @Override
    public int getCount() {
        return actionTypes.length;
    }

    @Override
    public Object getItem(int position) {
        return actionTypes[position];
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        SheduleActionType actionType=actionTypes[position];
        View itemView=inflater.inflate(R.layout.dialog_action_item_layout1,null);
        TextView actionNameView= (TextView) itemView.findViewById(R.id.operation_name);
        actionNameView.setText(actionType.getActionName());
        return itemView;
    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }

    @Override
    public int getViewTypeCount() {
        return 1;
    }

    @Override
    public boolean isEmpty() {
        return false;
    }
}
